package com.zlz.blog.websocket.相加;

/**
 * @author wb_zhulinzhong
 * @date 2021-06-16 15:52:05
 */
public class Main {

    public static void main(String[] args) {
        System.out.println(findMedianSortedArrays(new int[]{4, 5, 6, 9}, new int[]{2, 3}));
    }

    public static double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int len = nums1.length + nums2.length;
        int a = 0;
        int b = 0;
        return find(a,b, len, nums1, nums2);
    }

    private static double find(int a, int b, int len, int[] nums1, int[] nums2) {

        if(a+b < len/2){
            if(a == nums1.length-1){
                System.out.println(a +":" +b);
                System.out.println(nums2[b]);
                b++;
            }else if(b == nums2.length-1){
                System.out.println(a +":" +b);
                System.out.println(nums1[a]);
                a++;
            }else {
                if(nums1[a] < nums2[b]){
                    System.out.println(a +":" +b);
                    System.out.println(nums1[a]);
                    a++;
                }else {
                    System.out.println(a +":" +b);
                    System.out.println(nums2[b]);
                    b++;
                }
            }
            return find(a,b,len,nums1,nums2);
        }
        return 1;
    }


}
